import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsNotEmpty, IsOptional } from 'class-validator';

import { Permission } from '../entities/permissions.entity';

export class UpdateUserDto {
  @ApiProperty()
  @IsOptional()
  nickName?: string;
  @ApiProperty()
  @IsOptional()
  headPic?: string;
  @ApiProperty()
  @IsNotEmpty({ message: '邮箱不得为空' })
  @IsEmail({}, { message: '邮箱格式不合法' })
  email: string;
  @ApiProperty()
  @IsNotEmpty({ message: '验证码不得为空' })
  captcha: string;
}

export class CreateUserDto {
  @IsNotEmpty({ message: '用户名不得为空' })
  username: string;

  @IsNotEmpty({ message: '密码不得为空' })
  password: string;

  @IsOptional()
  nickName?: string;

  @IsNotEmpty({ message: '邮箱不得为空' })
  @IsEmail({}, { message: '不是合法的邮箱' })
  email: string;

  @IsOptional()
  headPic?: string;

  @IsOptional()
  phoneNumber?: string;

  @IsOptional()
  isFrozen?: boolean;

  @IsOptional()
  isAdmin?: boolean;

  roles: string[];

  permissions: Permission[];
}
export class LoginReturn {
  userInfo: CreateUserDto;
  accessToken?: string;
  refreshToken?: string;
}
